<template>
  <div>
    <a-form :model="sizeForm" layout="vertical" @submit-success="submit">
      <a-card :bordered="false">
        <a-form-item :label="t['宽度']" required>
          <a-input-number v-model="sizeForm.width"></a-input-number>
        </a-form-item>
        <a-form-item :label="t['高度']" required>
          <a-input-number v-model="sizeForm.height"></a-input-number>
        </a-form-item>
        <a-form-item :label="t['描述']" required>
          <a-textarea v-model="sizeForm.sizeDesc"></a-textarea>
        </a-form-item>
        <a-button :loading="loading" long type="primary" html-type="submit">
          {{ t["确定"] }}
        </a-button>
      </a-card>
    </a-form>
  </div>
</template>

<script setup lang="ts">
import { createLibrarySize, updateLibrarySize } from "@/api/service/library/size";

import { sizeList } from "../data/curd";
import { sizeForm, sizeShowForm } from "../data/form";
const t = translate("公共模块");
const loading = ref(false);
const submit = async () => {
  loading.value = true;
  if (sizeForm.value.sizeId) {
    await updateLibrarySize(sizeForm.value);
  } else {
    await createLibrarySize(sizeForm.value);
  }
  loading.value = false;
  sizeList();
  sizeShowForm.value = false;
};
</script>

<style lang="scss" scoped></style>
